import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CookieService } from 'ngx-cookie-service';

import { AppComponent, REDIRECT_ADDR, REST_ADDR, REST_URL } from './app.component';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { NavComponent } from './pages/nav/nav.component';
import { NZ_I18N } from 'ng-zorro-antd/i18n';
import { zh_CN } from 'ng-zorro-antd/i18n';
import { registerLocaleData } from '@angular/common';
import zh from '@angular/common/locales/zh';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AntdIncludeModule } from './utils/antd.include/antd.include.module';
import { SysModule } from './pages/sys.module';
import { NZ_ICONS, NzIconModule } from 'ng-zorro-antd/icon';
import { IconDefinition } from '@ant-design/icons-angular';
import * as AllIcons from '@ant-design/icons-angular/icons';
import { ResponseInterceptorService } from './services/response-interceptor.service';
import { ErrorInterceptorService } from './services/error-interceptor.service';
import { AppRoutingModule } from './app-routing.module';
import { ContentHeaderComponent } from './components/content-header/content-header.component';
import { ComponentsModule } from './components/components.module';

registerLocaleData(zh);

const antDesignIcons = AllIcons as unknown as {
  [key: string]: IconDefinition;
};
const icons: IconDefinition[] = Object.keys(antDesignIcons).map(key => antDesignIcons[key])


@NgModule({
  declarations: [
    AppComponent,
    NavComponent,
    ContentHeaderComponent,
    ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    HttpClientModule,
    BrowserAnimationsModule,
    AntdIncludeModule,
    ReactiveFormsModule,
    SysModule,
    ComponentsModule,
    NzIconModule.forRoot(icons),
  ],
  providers: [CookieService,
    { provide: REST_URL, useValue: `http://localhost:20120/` },
    { provide: REST_ADDR, useValue: `localhost`},
    { provide: REDIRECT_ADDR, useValue: `http://localhost:4200`},
    { provide: NZ_I18N, useValue: zh_CN },
    { provide: NZ_ICONS, useValue: icons },
    { provide: HTTP_INTERCEPTORS, useClass: ResponseInterceptorService, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptorService, multi: true },
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
